package com.example.excel.controller;

import com.alibaba.excel.EasyExcel;
import com.example.excel.excel.ComplexSubjectEasyExcel;
import com.example.excel.util.EasyExcelUtilsV1;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * description :
 * author :kang
 * create :2021-11-24 21:10:00
 */
@Slf4j
@RestController
@RequestMapping("/testmachine")
public class Testmachine {


    @ApiOperation("导出")
    @GetMapping(value = "/testRobot")
    public void testRobot(HttpServletResponse response) throws IOException {
        ComplexSubjectEasyExcel excel = new ComplexSubjectEasyExcel()
                .setSubjectId("1001")
                .setSubjectName("库存现金")
                .setFirstBorrowMoney(BigDecimal.valueOf(100))
                .setNowBorrowMoney(BigDecimal.valueOf(100))
                .setNowCreditMoney(BigDecimal.valueOf(100))
                .setYearBorrowMoney(BigDecimal.valueOf(100))
                .setYearCreditMoney(BigDecimal.valueOf(100))
                .setEndBorrowMoney(BigDecimal.valueOf(100));
        ComplexSubjectEasyExcel excel1 = new ComplexSubjectEasyExcel()
                .setSubjectId("1001")
                .setSubjectName("库存现金")
                .setFirstBorrowMoney(BigDecimal.valueOf(100))
                .setNowBorrowMoney(BigDecimal.valueOf(100))
                .setNowCreditMoney(BigDecimal.valueOf(100))
                .setYearBorrowMoney(BigDecimal.valueOf(100))
                .setYearCreditMoney(BigDecimal.valueOf(100))
                .setEndBorrowMoney(BigDecimal.valueOf(100));
        ComplexSubjectEasyExcel excel2 = new ComplexSubjectEasyExcel()
                .setSubjectId("1002")
                .setSubjectName("库存现金2")
                .setFirstBorrowMoney(BigDecimal.valueOf(100))
                .setNowBorrowMoney(BigDecimal.valueOf(100))
                .setNowCreditMoney(BigDecimal.valueOf(100))
                .setYearBorrowMoney(BigDecimal.valueOf(100))
                .setYearCreditMoney(BigDecimal.valueOf(100))
                .setEndBorrowMoney(BigDecimal.valueOf(100));
        ComplexSubjectEasyExcel excel3 = new ComplexSubjectEasyExcel()
                .setSubjectId("1002")
                .setSubjectName("库存现金2")
                .setFirstBorrowMoney(BigDecimal.valueOf(100))
                .setNowBorrowMoney(BigDecimal.valueOf(100))
                .setNowCreditMoney(BigDecimal.valueOf(100))
                .setYearBorrowMoney(BigDecimal.valueOf(100))
                .setYearCreditMoney(BigDecimal.valueOf(100))
                .setEndBorrowMoney(BigDecimal.valueOf(100));
        ComplexSubjectEasyExcel excel4 = new ComplexSubjectEasyExcel()
                .setSubjectId("1002")
                .setSubjectName("库存现金2")
                .setFirstBorrowMoney(BigDecimal.valueOf(101))
                .setNowBorrowMoney(BigDecimal.valueOf(100))
                .setNowCreditMoney(BigDecimal.valueOf(100))
                .setYearBorrowMoney(BigDecimal.valueOf(100))
                .setYearCreditMoney(BigDecimal.valueOf(100))
                .setEndBorrowMoney(BigDecimal.valueOf(100));
        ComplexSubjectEasyExcel excel5 = new ComplexSubjectEasyExcel()
                .setSubjectId("1001")
                .setSubjectName("库存现金")
                .setFirstBorrowMoney(BigDecimal.valueOf(101))
                .setNowBorrowMoney(BigDecimal.valueOf(100))
                .setNowCreditMoney(BigDecimal.valueOf(100))
                .setYearBorrowMoney(BigDecimal.valueOf(100))
                .setYearCreditMoney(BigDecimal.valueOf(100))
                .setEndBorrowMoney(BigDecimal.valueOf(100));
        List<ComplexSubjectEasyExcel> excels = new ArrayList<>();
        excels.add(excel);
        excels.add(excel1);
        excels.add(excel2);
        excels.add(excel3);
        excels.add(excel4);
        excels.add(excel5);

        EasyExcelUtilsV1.defaultExportOssUrlResponse(excels, ComplexSubjectEasyExcel.class, response, "科目余额表", new HashMap<>());
    }


}
